package com.yy.cloud.openfeign;

import com.yy.cloud.entity.GoodsInfo;
import com.yy.cloud.param.ComplexModel;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商品服务Feign接口
 *
 * @date 2024/5/7
 */
@FeignClient(value = "goods-service", path = "/goods") // value = "goods-service" 指定服务名称，path="/goods":请求前缀
public interface GoodsServiceFeign {

    @GetMapping("/{goodsId}")
    String goodsDetail(@PathVariable("goodsId") int goodsId);

    @GetMapping("/detail")
    String goodsDetailByParams(@RequestParam("sellStatus") int sellStatus, @RequestParam("goodsId") int goodsId);

    @GetMapping("/listByIdArray")
    String[] listByIdArray(@RequestParam("goodsIds") Integer[] goodsIds);

    @GetMapping("/listByIdList")
    List<String> listByIdList(@RequestParam("goodsIds") List<Integer> goodsIds);

    /**
     * 修改商品的库存信息
     *
     * @param goodsInfo 原商品信息
     * @return 修改之后的商品信息
     */
    @PostMapping("/updateGoodsInfo")
    GoodsInfo updateGoodsInfo(@RequestBody GoodsInfo goodsInfo);

    /**
     * 模拟对复杂类型对象处理
     *
     * @param complexModel 复杂类型对象
     * @return 处理过的复杂对象
     */
    @PostMapping("/testComplexModel")
    ComplexModel testComplexModel(@RequestBody ComplexModel complexModel);
}
